package com.micro.ai.models.service;

import com.micro.ai.models.entity.FineTuningJob;

/**
 * 任务调度服务接口
 * 负责实际执行微调训练任务
 * 
 * @author micro-ai
 * @since 0.0.1
 */
public interface TaskSchedulerService {

    /**
     * 提交训练任务到调度器
     * 
     * @param job 微调任务
     * @return 外部任务ID（如果使用外部平台）
     */
    String submitTrainingJob(FineTuningJob job);

    /**
     * 取消训练任务
     * 
     * @param jobId 任务ID
     * @param externalJobId 外部任务ID（可选）
     */
    void cancelTrainingJob(String jobId, String externalJobId);

    /**
     * 查询任务状态
     * 
     * @param externalJobId 外部任务ID
     * @return 任务状态信息
     */
    TaskStatus queryTaskStatus(String externalJobId);

    /**
     * 任务状态信息
     */
    class TaskStatus {
        private String status; // pending, running, completed, failed
        private Double progressPercent;
        private Integer currentEpoch;
        private Integer totalEpochs;
        private Double trainingLoss;
        private Double evalLoss;
        private String errorMessage;

        // Getters and Setters
        public String getStatus() {
            return status;
        }

        public void setStatus(String status) {
            this.status = status;
        }

        public Double getProgressPercent() {
            return progressPercent;
        }

        public void setProgressPercent(Double progressPercent) {
            this.progressPercent = progressPercent;
        }

        public Integer getCurrentEpoch() {
            return currentEpoch;
        }

        public void setCurrentEpoch(Integer currentEpoch) {
            this.currentEpoch = currentEpoch;
        }

        public Integer getTotalEpochs() {
            return totalEpochs;
        }

        public void setTotalEpochs(Integer totalEpochs) {
            this.totalEpochs = totalEpochs;
        }

        public Double getTrainingLoss() {
            return trainingLoss;
        }

        public void setTrainingLoss(Double trainingLoss) {
            this.trainingLoss = trainingLoss;
        }

        public Double getEvalLoss() {
            return evalLoss;
        }

        public void setEvalLoss(Double evalLoss) {
            this.evalLoss = evalLoss;
        }

        public String getErrorMessage() {
            return errorMessage;
        }

        public void setErrorMessage(String errorMessage) {
            this.errorMessage = errorMessage;
        }
    }
}

